package com.example.xiaomi.mapper;

import com.example.xiaomi.entity.contents;
import com.example.xiaomi.entity.hot;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.List;

@Mapper
public interface ContentsMapper {
    @Select("SELECT mid, contents, user_name, topic, date, repost_num, comment_num, like_num\n" +
            "FROM film\n" +
            "WHERE date >= DATE_SUB(CURDATE(), INTERVAL 10 DAY );")
    List<contents> findAllContents();

    @Select("select count('mid') as count_contents,\n" +
            "            SUM(repost_num) AS count_repost,\n" +
            "            sum(comment_num) as count_comment,\n" +
            "            sum(like_num) as count_like\n" +
            "            from film;")
    List<contents>  findContentsAccount();

    @Select("SELECT mid,user_name,contents,date,repost_num,comment_num,like_num\n" +
            "            FROM film\n" +
            "            where mid=#{mid}")
    List<contents> findContentsById(@PathVariable("mid") Integer mid);

    @Select("SELECT mid,user_name,contents,date,repost_num,comment_num,like_num\n" +
            "FROM film\n" +
            "where contents=#{contents};")
    List<contents> findContentsByContents(String contents);

    @Select("SELECT date, COUNT(mid) AS num_contents\n" +
            "FROM film\n" +
            "GROUP BY  date  \n" +
            "ORDER BY date;")
    List<contents> findContentsByDate();
    @Select ("SELECT * FROM xiaomi.contents_class where stage_idx=#{stage_idx} and topic_idx=#{topic_idx};")
    List<contents> findContentsTopic(@Param("stage_idx") Integer stage_idx,@Param("topic_idx")Integer topic_idx);
    @Select ("SELECT * FROM contents_class;")
    List<contents> findContentsTopic1();


}
